﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Simhopp.Model;

namespace Simhopp.GUI
{
    public partial class frmManageCompetition : Form, InterfaceManageCompetitionView
    {
        public event DelegateRemoveCompetition EventRemoveCompetition = null;
        public event DelegateUpdateCompetition EventUpdateCompetition = null;
        public event DelegateUpdateInformation EventUpdateInformation = null;
         
        public frmManageCompetition()
        {
            InitializeComponent();
            cmbAgeClass.Items.AddRange(Enum.GetNames(typeof(Simhopp.Model.AgeClass)));
            cmbCompetitionType.Items.AddRange(Enum.GetNames(typeof(Simhopp.Model.CompetitionType)));
            cmbHeight.Items.AddRange(Enum.GetNames(typeof(Simhopp.Model.Height)));
            cmbNationality.Items.AddRange(Enum.GetNames(typeof(Simhopp.Model.Countries)));
        }

        private void frmManageCompetition_Load(object sender, EventArgs e)
        {
            

            Competition competition = EventUpdateInformation();

            lblCompetitionName.Text = competition.Name.ToString();

            txtName.Text = competition.Name.ToString();
            cmbCompetitionType.SelectedIndex = (int)competition.Event;
            cmbAgeClass.SelectedIndex = (int)competition.AgeClass;
            cmbHeight.SelectedIndex = (int)competition.Height;
            if (competition.Gender == 'F')
            {
                rdoFemale.Select();
            }
            else if (competition.Gender == 'M')
            {
                rdoMale.Select();
            }
            txtLocation.Text = competition.Location.ToString();
            cmbNationality.SelectedIndex = (int)competition.Country;
            
        }

        public string GetCountryString()
        {
            string strCountry = cmbNationality.SelectedItem.ToString();
            strCountry = strCountry.Replace("_", " ");
            return strCountry;
        }

        private void btnReturn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
